#ifndef CARDREADERDEV_H
#define CARDREADERDEV_H

#include <QChar>
#include <QByteArray>
#include <QString>

//#include "inc_def.h"
#include "hyScript.h"

namespace SDHuaYi_Script
{
    enum EnumReaderType
    {
        READER_D8 = 0,
        READER_PCSC = 1,
        READER_E102S = 2,
        READER_HY3M3 = 3,
        READER_TCPS = 4
    };

    enum EnumReaderInterfaceType
    {
        Reader_Contactless = 0,
        Reader_Contact = 1,
    };

    class STCard
    {
    public:
        // 卡句柄
        qint32 hCard;
        // 卡ATS
        QString strATS;
        // 卡UID
        QString strUID;
        // 卡ATQA
        QString sATQA;
        // 卡SAK
        QString sSAK;

    public:
        STCard();
        STCard(qint32 hCard) : hCard(hCard) {}
    };

    enum EnumReaderPosType
    {
        POS_INSIDE = 0,
        POS_MIDSIDE = 1,
        POS_OUTSIDE = 2,
        POS_UNKNOW = 3
    };

    // TODO:封装的雪飞提供的接口
    class cardReaderDev
    {
    public:
        EnumReaderType readerType;

        STCard Card = STCard(0);

        qint32 Num = 0;

        QString m_response = {};
        QString m_ss = {};

        /* 记录指令执行用时，暂未使用 */
        qint32 SpendTime = 0;

        QString Response()
        {
            return m_response;
        }

        QString SS()
        {
            return m_ss;
        }
        // TODO:向下有很多未添加的内容

        // tips:对读卡器接口的调用，在使用时需先导入读卡器指针
        ICardReader *piReader;
        void setICardReader(ICardReader *pinReader)
        {
            piReader = pinReader;
        }

    public:
        cardReaderDev();

        bool CardReset();
        bool SendAPDU(QString sendMessage);
    };

    class HY_RSA_PUBLIC_KEY
    {
        qint32 modLen;     // 公钥模长
        QByteArray exp;    // 公钥指数
        QByteArray module; // 公钥模

    public:
        HY_RSA_PUBLIC_KEY();
        HY_RSA_PUBLIC_KEY(qint32 modLen, QByteArray exp, QByteArray module) : modLen(modLen), exp(exp), module(module){}
    };

}
#endif // CARDREADERDEV_H
